import config


class ApproveTrustAPI:

    # 1、 认证
    @classmethod
    def approve(cls, session, realname, card_id):
        url = config.Host + "/member/realname/approverealname"
        body = {"realname": realname, "card_id": card_id}
        resp = session.post(url=url, data=body, files={"x": "y"})
        return resp

    # 2、 获取认证信息
    @classmethod
    def get_approve_info(cls, session):
        url = config.Host + "/member/member/getapprove"
        resp = session.post(url)
        return resp

    # 3、后台开户
    @classmethod
    def trust(cls, session):
        url = config.Host + "/trust/trust/register"
        resp = session.post(url)
        return resp

    # 4、获取充值验证码
    @classmethod
    def get_recharge_code(cls, session, r):
        url = config.Host + f"/common/public/verifycode/{r}"
        resp = session.get(url)
        return resp

    # 5、后台充值
    @classmethod
    def recharge(cls, session, valicode):
        url = config.Host + "/trust/trust/recharge"
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        body = {"paymentType": "chinapnrTrust", "amount": "100", "formStr": "reForm", "valicode": valicode}
        resp = session.post(url=url, headers=headers, data=body)
        return resp
